package com.jinbo.footmessage;

import android.app.Application;
import android.os.Environment;


import com.baidu.mapapi.SDKInitializer;
import com.jinbo.footmessage.utils.LocalPreferencesHelper;

import java.io.File;

/**
 * Created by fangjinbo
 */
public class MyApplication extends Application {
    public static MyApplication app;
    public static LocalPreferencesHelper local;

    @Override
    public void onCreate() {
        super.onCreate();

        local=new LocalPreferencesHelper(this, LocalPreferencesHelper.DB_NAME);
        app = this;
        //在使用百度SDK各组件之前初始化context信息，传入ApplicationContext
        SDKInitializer.initialize(this);
    }
   public String getTmpDirName() {
        return "FootMessage";
    }


    /**
     * 获取临时目录
     *
     * @param //isSdcard
     *            是否取sd卡上的目录
     * @return
     */
/*
     public File getTmpDir(boolean isSdcard) {
        File tmpDir = null;
        // 判断sd卡是否存在
        boolean sdCardExist = Environment.getExternalStorageState().equals(
                Environment.MEDIA_MOUNTED);
        if(isSdcard&&sdCardExist) {
            tmpDir = new File(Environment.getExternalStorageDirectory(),
                    getTmpDirName());
        }
        else
        {
            tmpDir = new File(getCacheDir(), getTmpDirName());//getCacheDir():data/data 应该得ROOT，才能看到
        }

        if (!tmpDir.exists()) {

            tmpDir.mkdirs();
        }

        return tmpDir;
    }
*/

    public File getTmpDir() {
        //return getTmpDir(true);
        return new File(Environment.getExternalStorageDirectory(),
                getTmpDirName());
    }

}